import { Entity, PrimaryGeneratedColumn, Column, CreateDateColumn, UpdateDateColumn, RelationId, ManyToOne, JoinColumn } from "typeorm";
import { Category } from "../category/category.entity";
import { IsNotEmpty, IsString } from "class-validator";

@Entity('article')
export class Article {
  /**
   * id
   */
  @PrimaryGeneratedColumn()
  id: number
  /**
   * 标题
   */
  @IsNotEmpty({ message: '缺少参数？' })
  @IsString({ message: '标题格式不对？' })
  @Column()
  title: string
  /**
   * 标题
   */
  @IsNotEmpty({ message: '缺少参数？' })
  @IsString({ message: '图片格式不对？' })
  @Column()
  pic: string
  /**
   * 作者
   */
  @IsNotEmpty({ message: '缺少参数？' })
  @IsString({ message: '作者格式不对？' })
  @Column({
    length: 40
  })
  author: string

  /**
   * 文章内容
   */
  @IsNotEmpty({ message: '缺少参数？' })
  @IsString({ message: '内容格式不对？' })
  @Column('text')
  content: string
  /**
   * 创建时间
   */
  @CreateDateColumn()
  createDate: Date = new Date()
  /**
   * 修改时间
   */
  @UpdateDateColumn()
  updateDate: Date = new Date()
  
  /**
   * 关键字，方便搜索引擎爬取
   */
  @Column({
    type: 'simple-array',
  })
  keywords: Array<string>

  authorInfo: any
}